#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
typedef pair<int, int> PII;
#define x first
#define y second
const int N = 1e5 + 10;
int last[N];
int arr[N];
bool st[N];
int n, m, T;
PII order[N];
int main()
{
    scanf("%d%d%d", &n, &m, &T);
    for (int i = 0; i < m; i++) {
        int x, y;
        scanf("%d%d", &x, &y);
        order[i] = { x,y };
    }
    sort(order, order + m);
    for (int i = 0; i < m; ) {
        int j = i;
        while (j < m && order[i] == order[j]) {
            j++;
        }
        int t = order[i].x, id = order[i].y;
        int cnt = j - i;
        i = j;
        arr[id] -= t - last[id] - 1;
        if (arr[id] < 0) {
            arr[id] = 0;
        }
        if (arr[id] <= 3) {
            st[id] = 0;
        }
        arr[id] += cnt * 2;
        if (arr[id] > 5) {
            st[id] = 1;
        }
        last[id] = t;
    }
    for (int i = 1; i <= n; i++) {
        if (last[i] < T) {
            arr[i] -= T - last[i];
            if (arr[i] <= 3) {
                st[i] = 0;
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (st[i]) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}